using System;
using NUnit.Framework;

namespace OpenWaves.UnitTests
{
    [TestFixture]
    public class FakeTimeTests
    {
        [Test]
        public void When_in_FakeTimeScope_Then_TimeNow_returns_fake_time()
        {
            var fakeTime = new DateTime(2000, 1, 2, 3, 4, 5, 6);
            using (FakeTimeScope.Begin(fakeTime))
            {
                Assert.That(Time.Now, Is.EqualTo(fakeTime));
            }
        }

        [Test]
        public void When_FakeTimeScope_is_disposed_Then_TimeNow_returns_utc_time()
        {
            var fakeDate = new DateTime(2000, 1, 2, 3, 4, 5, 6);
            using (var fakeTimeScope = FakeTimeScope.Begin(fakeDate))
            {
            }

            Assert.That(Time.Now, Is.EqualTo(DateTime.UtcNow).Within(100).Milliseconds);
        }
    }
}